<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
        
      <button type="button">点击</button>
      <hr>
      <label for="">性别</label>
      <input type="radio" name='gender' id='M' checked  value="M">男
      <input type="radio" name='gender' value="F">女
      <hr>

    <label for="">爱好</label>
      <input type="checkbox" name='aihao' id='sport' checked  value="sport">体育
      <input type="checkbox" name='aihao' value="muisc">音乐

</body>
</html>
<script>

    /*
    操作单选框和复选框都是操作 checked的属性   

    checked=true  选中状态
     checked=false  未选中状态

    */

    document.getElementsByTagName('button')[0].onclick=()=>{

      //document.getElementById('M').checked=true;
      //document.getElementById('M').checked=false;
    }


</script>